package com.kl.airticketserver.dto;

public class Result<T> {
    private Integer code;
    private boolean success;
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.success = true;
        result.data = data;
        result.code = 0;
        return result;
    }

    public static <T> Result<T> error(String message) {
        return error(500,message);
    }

    public static <T> Result<T> error(Integer code,String message) {
        Result<T> result = new Result<>();
        result.success = false;
        result.message = message;
        result.code = null==code?500:code;
        return result;
    }

    // Getters and Setters
    public boolean isSuccess() { return success; }
    public void setSuccess(boolean success) { this.success = success; }
    
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
    
    public T getData() { return data; }
    public void setData(T data) { this.data = data; }
}